\hypertarget{class_cache}{
\section{Cache Class Reference}
\label{class_cache}\index{Cache@{Cache}}
}


manage list of cache items per frame and writes them to disk at a regular interval  




{\ttfamily \#include $<$Cache.h$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{class_cache_a486f257a48e32d0083f8ae41f78074d1}{Cache} ()
\begin{DoxyCompactList}\small\item\em ctor \end{DoxyCompactList}\item 
void \hyperlink{class_cache_ad877f1c11ae309de29307bd84db3e5b1}{addItem} (const \hyperlink{class_cache_item}{CacheItem} \&\_\-cacheItem)
\begin{DoxyCompactList}\small\item\em add cache items to the cache \end{DoxyCompactList}\item 
int \hyperlink{class_cache_a1b4dc3d195bb26cda0c5a9ead4d128a7}{getCacheCount} () const 
\begin{DoxyCompactList}\small\item\em return the number of items in the cache \end{DoxyCompactList}\item 
void \hyperlink{class_cache_a4c1e595b63829157ca8d3a8ebdecc2f8}{flushCache} (const std::string \_\-path)
\begin{DoxyCompactList}\small\item\em writes the contents of the cache to file \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{class_cache_ad0c0f5590631d8938cf71d66df462a1a}{writePointData} (std::vector$<$ ngl::Vector $>$ \&\_\-positionList, const std::string \&\_\-filename)
\begin{DoxyCompactList}\small\item\em write point positions (fluid and sphere) to file \end{DoxyCompactList}\item 
void \hyperlink{class_cache_af479c672de491afacd1b940108b86ed7}{writeBoundaryData} (std::vector$<$ ngl::Vector $>$ \&\_\-positionList, const std::string \&\_\-filename)
\begin{DoxyCompactList}\small\item\em write the boundary box information to file \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
std::vector$<$ \hyperlink{class_cache_item}{CacheItem} $>$ \hyperlink{class_cache_a04c0bf08e19074c26ab9f73623dab153}{m\_\-fluidCache}
\begin{DoxyCompactList}\small\item\em the list of cache items held in the cache \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
manage list of cache items per frame and writes them to disk at a regular interval 

Definition at line 16 of file Cache.h.



\subsection{Constructor \& Destructor Documentation}
\hypertarget{class_cache_a486f257a48e32d0083f8ae41f78074d1}{
\index{Cache@{Cache}!Cache@{Cache}}
\index{Cache@{Cache}!Cache@{Cache}}
\subsubsection[{Cache}]{\setlength{\rightskip}{0pt plus 5cm}Cache::Cache (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{class_cache_a486f257a48e32d0083f8ae41f78074d1}


ctor 



Definition at line 8 of file Cache.cpp.


\begin{DoxyCode}
{

}
\end{DoxyCode}


\subsection{Member Function Documentation}
\hypertarget{class_cache_ad877f1c11ae309de29307bd84db3e5b1}{
\index{Cache@{Cache}!addItem@{addItem}}
\index{addItem@{addItem}!Cache@{Cache}}
\subsubsection[{addItem}]{\setlength{\rightskip}{0pt plus 5cm}void Cache::addItem (
\begin{DoxyParamCaption}
\item[{const {\bf CacheItem} \&}]{\_\-cacheItem}
\end{DoxyParamCaption}
)}}
\label{class_cache_ad877f1c11ae309de29307bd84db3e5b1}


add cache items to the cache 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-cacheItem} & the item to add to the cache list \\
\hline
\end{DoxyParams}


Definition at line 13 of file Cache.cpp.



References m\_\-fluidCache.


\begin{DoxyCode}
{
    m_fluidCache.push_back(_cacheItem);
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_cache_ad877f1c11ae309de29307bd84db3e5b1_icgraph}
\end{center}
\end{figure}


\hypertarget{class_cache_a4c1e595b63829157ca8d3a8ebdecc2f8}{
\index{Cache@{Cache}!flushCache@{flushCache}}
\index{flushCache@{flushCache}!Cache@{Cache}}
\subsubsection[{flushCache}]{\setlength{\rightskip}{0pt plus 5cm}void Cache::flushCache (
\begin{DoxyParamCaption}
\item[{const std::string}]{\_\-path}
\end{DoxyParamCaption}
)}}
\label{class_cache_a4c1e595b63829157ca8d3a8ebdecc2f8}


writes the contents of the cache to file 



Definition at line 18 of file Cache.cpp.



References BOUNDARY\_\-CACHE, CAPSULE\_\-CACHE, FLUID\_\-CACHE, CacheItem::getCacheItemType(), CacheItem::getFrameNumber(), CacheItem::getNameList(), CacheItem::getPositionList(), m\_\-fluidCache, SPHERE\_\-CACHE, writeBoundaryData(), and writePointData().


\begin{DoxyCode}
{
    //loop through cache items
    for (int i = 0; i < m_fluidCache.size(); ++i)
    {
        //get cache item
        CacheItem item = m_fluidCache[i];

        //loop through name list of the item
        for (int j = 0; j < item.getNameList().size(); ++j)
        {
            //determine type of item
            std::string itemType;
            if (item.getCacheItemType() == FLUID_CACHE)
                itemType = "Fluid";
            else if (item.getCacheItemType() == BOUNDARY_CACHE)
                itemType = "Boundary";
            else if (item.getCacheItemType() == SPHERE_CACHE)
                itemType = "Sphere";
            else if (item.getCacheItemType() == CAPSULE_CACHE)
                itemType = "Capsule";
            else
                itemType = "NA";

            //construct filename of the item for the current frame number
            QString text = QString("%1%2_%3_Frame_%4.geo")
                            .arg(_path.c_str())
                            .arg(itemType.c_str())
                            .arg(std::string(item.getNameList()[j]).c_str())
                            .arg(item.getFrameNumber());

            //write data to file
            if (item.getCacheItemType() == FLUID_CACHE || item.getCacheItemType()
       == SPHERE_CACHE || item.getCacheItemType() == CAPSULE_CACHE)
                writePointData(item.getPositionList()[j], text.toStdString());
            else if (item.getCacheItemType() == BOUNDARY_CACHE)
                writeBoundaryData(item.getPositionList()[j], text.toStdString());
      

        }
    }

    //clear cache
    m_fluidCache.clear();
}
\end{DoxyCode}


Here is the call graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=364pt]{class_cache_a4c1e595b63829157ca8d3a8ebdecc2f8_cgraph}
\end{center}
\end{figure}




Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_cache_a4c1e595b63829157ca8d3a8ebdecc2f8_icgraph}
\end{center}
\end{figure}


\hypertarget{class_cache_a1b4dc3d195bb26cda0c5a9ead4d128a7}{
\index{Cache@{Cache}!getCacheCount@{getCacheCount}}
\index{getCacheCount@{getCacheCount}!Cache@{Cache}}
\subsubsection[{getCacheCount}]{\setlength{\rightskip}{0pt plus 5cm}int Cache::getCacheCount (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{class_cache_a1b4dc3d195bb26cda0c5a9ead4d128a7}


return the number of items in the cache 



Definition at line 27 of file Cache.h.



References m\_\-fluidCache.


\begin{DoxyCode}
{ return m_fluidCache.size(); }
\end{DoxyCode}
\hypertarget{class_cache_af479c672de491afacd1b940108b86ed7}{
\index{Cache@{Cache}!writeBoundaryData@{writeBoundaryData}}
\index{writeBoundaryData@{writeBoundaryData}!Cache@{Cache}}
\subsubsection[{writeBoundaryData}]{\setlength{\rightskip}{0pt plus 5cm}void Cache::writeBoundaryData (
\begin{DoxyParamCaption}
\item[{std::vector$<$ ngl::Vector $>$ \&}]{\_\-positionList, }
\item[{const std::string \&}]{\_\-filename}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_cache_af479c672de491afacd1b940108b86ed7}


write the boundary box information to file 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-positionList} & the position list to write out \\
\hline
\mbox{\tt in}  & {\em \_\-filename} & the name of the file on disk \\
\hline
\end{DoxyParams}


Definition at line 96 of file Cache.cpp.


\begin{DoxyCode}
{
    //open file for writing
    std::ofstream outFile(_filename.c_str(), std::ios::out);

    //write header
    outFile << "PGEOMETRY V5\n";
    outFile << "NPoints 8 NPrims 6\n";
    outFile << "NPointGroups 0 NPrimGroups 0\n";
    outFile << "NPointAttrib 0 NVertexAttrib 0 NPrimAttrib 0 NAttrib 0\n";

    //loop through position list
    for (int i = 0; i < _positionList.size(); ++i)
    {
        outFile
                << _positionList[i].m_x << " "
                << _positionList[i].m_y << " "
                << _positionList[i].m_z << " "
                << _positionList[i].m_w << "\n";
    }

    //write box vertex connections
    outFile << "Run 6 Poly\n";
    outFile << " 4 < 1 5 4 0\n";
    outFile << " 4 < 2 6 5 1\n";
    outFile << " 4 < 3 7 6 2\n";
    outFile << " 4 < 0 4 7 3\n";
    outFile << " 4 < 2 1 0 3\n";
    outFile << " 4 < 5 6 7 4\n";

    //write the outro
    outFile << "beginExtra\n";
    outFile << "endExtra";

    //close file
    outFile.close();
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_cache_af479c672de491afacd1b940108b86ed7_icgraph}
\end{center}
\end{figure}


\hypertarget{class_cache_ad0c0f5590631d8938cf71d66df462a1a}{
\index{Cache@{Cache}!writePointData@{writePointData}}
\index{writePointData@{writePointData}!Cache@{Cache}}
\subsubsection[{writePointData}]{\setlength{\rightskip}{0pt plus 5cm}void Cache::writePointData (
\begin{DoxyParamCaption}
\item[{std::vector$<$ ngl::Vector $>$ \&}]{\_\-positionList, }
\item[{const std::string \&}]{\_\-filename}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_cache_ad0c0f5590631d8938cf71d66df462a1a}


write point positions (fluid and sphere) to file 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em \_\-positionList} & the position list to write out \\
\hline
\mbox{\tt in}  & {\em \_\-filename} & the name of the file on disk \\
\hline
\end{DoxyParams}


Definition at line 63 of file Cache.cpp.


\begin{DoxyCode}
{
    //open file for writing
    std::ofstream outFile(_filename.c_str(), std::ios::out);

    //write header
    outFile << "PGEOMETRY V5\n";
    outFile << "NPoints " << _positionList.size() << " NPrims 0\n";
    outFile << "NPointGroups 0 NPrimGroups 0\n";
    outFile << "NPointAttrib 0 NVertexAttrib 0 NPrimAttrib 0 NAttrib 0\n";

    //loop through position list
    for (int i = 0; i < _positionList.size(); ++i)
    {
        outFile
                << _positionList[i].m_x << " "
                << _positionList[i].m_y << " "
                << _positionList[i].m_z << " "
                << _positionList[i].m_w << "\n";
    }

    //write the outro
    outFile << "beginExtra\n";
    outFile << "endExtra";

    //close file
    outFile.close();
}
\end{DoxyCode}


Here is the caller graph for this function:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=400pt]{class_cache_ad0c0f5590631d8938cf71d66df462a1a_icgraph}
\end{center}
\end{figure}




\subsection{Member Data Documentation}
\hypertarget{class_cache_a04c0bf08e19074c26ab9f73623dab153}{
\index{Cache@{Cache}!m\_\-fluidCache@{m\_\-fluidCache}}
\index{m\_\-fluidCache@{m\_\-fluidCache}!Cache@{Cache}}
\subsubsection[{m\_\-fluidCache}]{\setlength{\rightskip}{0pt plus 5cm}std::vector$<${\bf CacheItem}$>$ {\bf Cache::m\_\-fluidCache}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{class_cache_a04c0bf08e19074c26ab9f73623dab153}


the list of cache items held in the cache 



Definition at line 34 of file Cache.h.



The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
include/\hyperlink{_cache_8h}{Cache.h}\item 
src/\hyperlink{_cache_8cpp}{Cache.cpp}\end{DoxyCompactItemize}
